package com.satis.compose.get.example.viewmodel
import android.util.Log
import androidx.lifecycle.MutableLiveData
import com.satis.compose.get.GetViewModel
import com.satis.compose.get.example.intent.MainIntent
import com.satis.compose.get.example.uistate.MainUiState


/**
 * @author sunshaobei on 2022/9/9
 */
class MainViewMode :GetViewModel<MainIntent,MainUiState>(){
    override suspend fun dispatch(it: MainIntent) {
        uiState = when(it){
            is MainIntent.VisibleIntent -> {
                uiState.copy(visibile = MutableLiveData(it.visible))
            }
            else -> {
                uiState.copy(title = "Main Title")
            }
        }

    }

    override fun onCleared() {
        super.onCleared()
        Log.e(MainViewMode::class.java.name,"onCleared")
    }
}